<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>


    function fun(arr) {

        if (!arr.length) {
            return arr
        }

        Object.keys(arr[0]).forEach(x => {
            arr.forEach(y => {
                if (!y[x]) {
                    y[x] = '--'
                }
            })
        })

        return arr
    }

    let arr = [{name: 'jack', age: undefined}, {name: null, age: 20}, {name: null, age: undefined}]
    console.log(fun(arr))
</script>
</body>
</html>
